package com.wutong.eams.controller;

import com.wutong.eams.enums.RequestMethod;
import com.wutong.eams.enums.Role;
import com.wutong.eams.interfaces.PageAttributeSetting;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
@WebServlet("/page/*")
public class PageController extends BaseController  {

    @Override
    public Role getPermission() {
        return Role.USER;
    }

    @Override
    public boolean needPermission() {
        return false;
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
        log.debug("PageController doGet: {}", req.getRequestURI().split("/page")[1].trim());
        String uri = req.getPathInfo();
        if (uri.startsWith("/")) {
            uri = uri.replaceFirst("/", "");
        }
        viewForward(uri + ".jsp", req, resp);
    }
}
